package com.liu.cloud;

import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties;
import org.jasypt.encryption.StringEncryptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import javax.annotation.PostConstruct;

/**
 * nacos加密配置
 * @author LIU
 * @version 1.0
 * @description: TODO
 * @date 2023/6/18 12:56
 */
@EnableEncryptableProperties
@SpringBootApplication
public class NacosConfigEncryptApplication {

    public static void main(String[] args) {
        SpringApplication.run(NacosConfigEncryptApplication.class, args);
    }

    @Autowired
    private StringEncryptor stringEncryptor;

    @PostConstruct
    void encryptPwd() {

        // 给原账号生成加密后的用户名
        String username = stringEncryptor.encrypt("root");

        // 给原密码生成加密后的密码
        String pwd = stringEncryptor.encrypt("root123");
        System.err.println("------------username----------------");
        System.err.println(username);
        System.err.println("------------pwd----------------");
        System.err.println(pwd);
    }




}
